import { useState } from 'react';
/**
 * 运行时配置
 */
// layout默认返回一个对象
export const layout = {
  name: 'EXAMPLE-UMI3',
  logout: () => {},
};

// 全局初始数据
// 注入到namespace为@@initialState的model中
// 可通过useModel('@@initialState')来获取这份数据
export async function getInitialState() {
  return {
    name: 'bxj',
  };
}

// qiankun-步骤2.注册qiankun微应用
export const qiankun = {
  //所有子应用信息
  apps: [
    {
      name: 'app1',
      entry: '//localhost:8001/',
      props: {
        params1: '111',
      },
    },
    { name: 'app2', entry: '//localhost:8002/' },
  ],
};
// 报错Error: register failed, invalid key useQiankunStateForSlave from plugin ../../app.tsx.为什么？-根据报错信息可知道src/.umi/core/plugins中没有useQiankunStateForSlave
export function useQiankunStateForSlave() {
  const [globalState, setQiankunGlobalState] = useState({ str: 'aaa' });
  return {
    globalState,
    setQiankunGlobalState,
  };
}
